import {createRouter,createWebHistory} from 'vue-router'

const router=new createRouter({
    scrollBehavior (to, from, savedPosition) {
        return { x: 0, y: 0 }
    },
    history: createWebHistory(),
    routes:[
        {
            path:'/home',
            component:()=>import('@/pages/Home')
        },
        {
            path:'/login',
            component:()=>import('@/pages/Login')
        },
        {
            path:'/register',
            component:()=>import('@/pages/Register')
        },
        {
            path:'/myself',
            component:()=>import('@/pages/MySelf')
        },
        {
            path:'/admin',
            component:()=>import('@/pages/Admin'),
            children:[
                {   path:'/user',
                    component:()=>import('@/components/AdminUser')
                },
                {   path:'/category',
                    component:()=>import('@/components/AdminCategory')
                }
            ]
        },
        {
            //路由匹配
            path: '/:pathMatch(.*)*',
            redirect:'/home'
        }
    ]
})
export default router
